<html layout:decorator="bootstrap/layout/layout">
<head>
    <title>登录</title>
</head>
<body>
<div layout:fragment="content">
    <div class="row">
        <div class="col-md-9">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <a href="/">主页</a> / 注册
                </div>
                <div class="panel-body">
                    <div class="alert alert-danger" th:if="${errors}" th:text="${errors}"></div>
                    <form role="form" th:action="@{/register}" method="post" id="form">
                        <!-- <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/> -->
                        <div class="form-group">
                            <label for="username">用户名</label>
                            <input type="text" class="form-control" id="username" name="username" placeholder="用户名"/>
                        </div>
                        <div class="form-group">
                            <label for="password">密码</label>
                            <input type="password" class="form-control" id="password" name="password" placeholder="密码"/>
                        </div>
                        <button type="submit" class="btn btn-default">注册</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script th:inline="javascript">
        /*<![CDATA[*/
        $(function () {
            $("#form").submit(function () {
                var username = $("#username").val();
                var password = $("#password").val();
                if(username.length === 0) {
                    layui.msg("用户名不能为空", {icon: 2});
                    return false;
                }
                if(password.length === 0) {
                    layui.msg("密码不能为空", {icon: 2});
                    return false;
                }
            })
        });
        /*]]>*/
    </script>
</div>
</body>
</html>